package com.ruoyi.community.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.community.domain.vo.ExerciseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.community.mapper.ExerciseMapper;
import com.ruoyi.community.domain.Exercise;
import com.ruoyi.community.service.IExerciseService;

/**
 * 活动Service业务层处理
 *
 * @author lj
 * @date 2022-02-25
 */
@Service
public class ExerciseServiceImpl implements IExerciseService
{
    @Autowired
    private ExerciseMapper exerciseMapper;

    /**
     * 查询活动
     *
     * @param id 活动主键
     * @return 活动
     */
    @Override
    public Exercise selectExerciseById(Long id)
    {
        return exerciseMapper.selectExerciseById(id);
    }

    /**
     * 查询活动列表
     *
     * @param exercise 活动
     * @return 活动
     */
    @Override
    public List<Exercise> selectExerciseList(Exercise exercise)
    {
        List<Exercise> exercises=exerciseMapper.selectExerciseList(exercise);
        for (Exercise exercise1 : exercises) {


        }

        return exercises;
    }

    @Override
    public List<ExerciseVo> selectExerciseLists(Exercise exercise) {
        return exerciseMapper.selectExerciseLists(exercise);
    }

    /**
     * 新增活动
     *
     * @param exercise 活动
     * @return 结果
     */
    @Override
    public int insertExercise(Exercise exercise)
    {
        exercise.setCreatTime(DateUtils.getNowDate());
        exercise.setUpdateTime(DateUtils.getNowDate());
        exercise.setDelFlag(0);
        return exerciseMapper.insertExercise(exercise);
    }

    /**
     * 修改活动
     *
     * @param exercise 活动
     * @return 结果
     */
    @Override
    public int updateExercise(Exercise exercise)
    {
        exercise.setUpdateTime(DateUtils.getNowDate());
        return exerciseMapper.updateExercise(exercise);
    }

    /**
     * 批量删除活动
     *
     * @param ids 需要删除的活动主键
     * @return 结果
     */
    @Override
    public int deleteExerciseByIds(Long[] ids)
    {
        return exerciseMapper.deleteExerciseByIds(ids);
    }

    /**
     * 删除活动信息
     *
     * @param id 活动主键
     * @return 结果
     */
    @Override
    public int deleteExerciseById(Long id)
    {
        return exerciseMapper.deleteExerciseById(id);
    }

    @Override
    public int updateExerciseByIds(Long[] ids) {
        return exerciseMapper.updateExerciseByIds(ids);
    }

    @Override
    public List<ExerciseVo> myExercise(Long userId) {
        return exerciseMapper.myExercise(userId);
    }
}
